package com.qianya.oa.mapper;


import com.qianya.oa.domain.SysHospital;
import com.qianya.oa.vo.SysHospitalVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface HospItalInfoMapper {

    List<SysHospital> selectAllHospitalServices(String name ,String lv );

    List<SysHospitalVo> selectConfrimHospital();

    List<SysHospitalVo> selectUnConfrimHospital();
    @Insert(
            "insert into sys_hospital ( hospital_name, hospital_address, hospital_lv, hospital_consortium, hospital_internet,\n" +
            "                          key_department, hospital_bad, hospital_service, target_department, doctor_number, high_number,\n" +
            "                          psychologist_number, main_patient_types, main_department_listing, head_man,\n" +
            "                          project_key_department, leader, dealer, dealer_head_man, phone, frist_count_time, fight_flag,\n" +
            "                          fight_information, create_time,img)\n" +
            "values (#{hospitalName},#{hospitalAddress},#{hospitalLv},#{hospitalConsortium},#{hospitalInternet},#{keyDepartment}," +
            "#{hospitalBad},#{hospitalService},#{targetDepartment},#{doctorNumber},#{highNumber},#{psychologistNumber},#{mainPatientTypes}," +
            "#{mainDepartmentListing},#{headMan},#{projectKeyDepartment},#{leader},#{dealer},#{dealerHeadMan},#{phone},#{fristCountTime}," +
            "#{fightFlag},#{fightInformation},#{createTime},#{img});")
    int addHospital(SysHospital sysHospital);

    @Update(
            "update sys_hospital\n" +
            "set  del_flag= 1\n" +
            "where id =#{id}")
    int deleteHospitalById(Integer id);

    @Update("UPDATE sys_hospital\n" +
            "SET hospital_name = #{hospitalName},\n" +
            "            hospital_address = #{hospitalAddress},\n" +
            "            hospital_lv = #{hospitalLv},\n" +
            "            hospital_consortium = #{hospitalConsortium},\n" +
            "            hospital_internet = #{hospitalInternet},\n" +
            "            key_department = #{keyDepartment},\n" +
            "            hospital_bad = #{hospitalBad},\n" +
            "            hospital_service = #{hospitalService},\n" +
            "            target_department = #{targetDepartment},\n" +
            "            doctor_number = #{doctorNumber},\n" +
            "            high_number = #{highNumber},\n" +
            "            psychologist_number = #{psychologistNumber},\n" +
            "            main_patient_types = #{mainPatientTypes},\n" +
            "            main_department_listing = #{mainDepartmentListing},\n" +
            "            head_man = #{headMan},\n" +
            "            project_key_department = #{projectKeyDepartment},\n" +
            "            leader = #{leader},\n" +
            "            dealer = #{dealer},\n" +
            "            dealer_head_man = #{dealerHeadMan},\n" +
            "            phone = #{phone},\n" +
            "            frist_count_time = #{fristCountTime},\n" +
            "            fight_flag = #{fightFlag},\n" +
            "            fight_information = #{fightInformation},\n" +
            "            create_time = #{createTime},\n" +
            "            img = #{img}\n" +
            "WHERE id = #{id};\n")
    int updateHospital(SysHospital sysHospital);

    @Select("select sr.role_key from sys_user AS su\n" +
            "INNER JOIN sys_user_role AS sur\n" +
            "on su.user_id = sur.user_id\n" +
            "INNER JOIN sys_role AS sr\n" +
            "on sur.role_id = sr.role_id\n" +
            "WHERE su.login_name = #{name}")
    String selLoginNow(String name);


}
